<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function action_bill($product)
{
	$action['submit']='member/vattu/submitbill/';
	$action['edit']='member/vattu/editbill/';
	action_display($action,$product);
}

function action_display($action,$product)
{
	echo '<label id="lblactionitem'. $product["id"] .'">';
	if($product['status'] == 0) // Vua moi them moi
	{
		echo anchor($action['submit'] . $product['id'], '<img src="' . base_url() . 'application/views/templates/default/images/enable.png" title="' . lang('enable') . '" border="0">');
		echo anchor($action['edit'].$product['id'], '<img src="' . base_url() . 'application/views/templates/default/images/edit.png" title="' . lang('edit') . '" border="0">');
	}
	elseif($product['status'] == 1) //da submit
	{
		echo '<img src="' . base_url() . 'application/views/templates/default/images/disable.png" title="' . lang('disable') . '" border="0">';
	}
	else // chua sua dung
	{

	}
	echo '</label>';
}

function get_typealias($type)
{
	$_arr_type = array(1=>"Vật tư",2=>"Trang thiết bị");
	return $_arr_type[$type];
}

function status_item($status,$item_id)
{
	echo '<label id="lblstatusitem'. $item_id .'">';
	if($status == 0) // Vua moi them moi
	{
		echo '<input type="checkbox" id="itemid'.$item_id .'" name="itemcheck[]" value="'.$item_id.'" class="case" >';
	}
	elseif($status == 1) //da submit
	{
		echo 'Đã xác nhận';
	}
	else // chua sua dung
	{
		
	}
	echo '</label>';
}

function action_item($product)
{
	echo '<label id="lblactionitem'. $product["id"] .'">';
	if($product['status'] == 0) // Vua moi them moi
	{
		echo anchor('member/hocvien/submit/' . $product['id'], '<img src="' . base_url() . 'application/views/templates/default/images/enable.png" title="' . lang('enable') . '" border="0">');
		echo anchor('member/vattu/edit/'.$product['id'], '<img src="' . base_url() . 'application/views/templates/default/images/edit.png" title="' . lang('edit') . '" border="0">');
	}
	elseif($product['status'] == 1) //da submit
	{
		echo '<img src="' . base_url() . 'application/views/templates/default/images/disable.png" title="' . lang('disable') . '" border="0">';
	}
	else // chua sua dung
	{
	
	}
	echo '</label>';
}

function tool_bar_item($products)
{
	$html = '<tr>';
	$html = $html . '<th colspan="6" align="right">';
	$html = $html . '<a onclick="submit();" onmouseover="this.style.cursor=\'pointer\';">Submit</a>';
	$html = $html . '</th>';
	$html = $html . '<th align="right">';
	$html = $html . '<input type="checkbox" name="selectall" id="selectall" />';
	$html = $html . '</th>';
	$html = $html . '</tr>';
	$count = 0;
	foreach($products as $product)
	{
		if($product['status']== 0)
		{
			$count = 1; break;
		}
	}
	if($count == 1)
	{
		echo $html;
	}
}
/*
 * display drop list box to select class
 * $prams is array with key is properties of select tag
 */
function droplistbox_class($object,$prams=null)
{
	$html = '';
	$header = '<select id="" name="" class="">';	
	$footer = '</select>';
	$arr = array();
	if(is_array($object))
	{
		foreach($object as $item)
		{
			$arr[$item['id']] = $item['tenlop'];
		} 
	}
	elseif(is_object($object)) 
	{
		foreach($object as $item)
		{
			$arr[$item->id] = $item->tenlop;
		}
	}	
	else{
		echo $html='';
		return;
	}	
	$selected = 'NA';
	$expanded = '';
	if(is_array($prams))
	{
		$selected = $prams['selected'];	
		
		foreach($prams as $key=>$value)
		{
			$expanded = $expanded . ' '. $key.'='.'"'.$value.'"';
		} 
	}	
	echo form_dropdown($prams['name'],$arr,$selected,$expanded);
}